﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

public class Solution153
{//思路找到比前面的值小的值
    public int FindMin(int[] nums)
    {

        int left= 0;
        int right= nums.Length-1;

        int mid=(left+right)/2;
        int min = nums[0];

        while (left <= right)
        {

            Console.WriteLine(nums[mid]);
         

                if (nums[mid] < min)//在左边
            {
                min= nums[mid];
                    right = mid - 1;
                }
                else
                {
                    left = mid + 1;
                }

            mid = (left + right) / 2;
            Console.WriteLine(right + "  left:  " + left+ "mid"+mid);
        }
       
        return min;
    }
}
class Program153
{
    static void Main153(string[] args)
    {


        Solution153 sol =new Solution153();
        int[] nums = [3, 4, 5, 1, 2];
        int res = sol.FindMin(nums);
        //int res = (3 + 4) / 2;
        Console.WriteLine(res);
    }
}
